package com.abe.abetest.album;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.abe.libbase.base.BaseRecyclerActivity;
import com.yanzhenjie.album.Action;
import com.yanzhenjie.album.Album;
import com.yanzhenjie.album.AlbumFile;

import java.util.ArrayList;

public class AlbumActivity extends BaseRecyclerActivity {

    @Override
    public void init() {
        btnNames = new String[]{
                "Image and video mix options", "Image Selection", "Video Selection",
                "Take Picture", "Record Video", "Gallery"};
        super.init();
    }

    @Override
    public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
        switch (position) {
            case 0:
                Album.album(getContext()) // Image and video mix options.
                        .multipleChoice() // Multi-Mode, Single-Mode: singleChoice().
                        .columnCount(3) // The number of columns in the page list.
                        .selectCount(3)  // Choose up to a few images.
                        .camera(true) // Whether the camera appears in the Item.
                        .cameraVideoQuality(1) // Video quality, [0, 1].
                        .cameraVideoLimitDuration(Long.MAX_VALUE) // The longest duration of the video is in milliseconds.
                        .cameraVideoLimitBytes(Long.MAX_VALUE) // Maximum size of the video, in bytes.
                        //.checkedList() // To reverse the list.
                        //.filterSize() // Filter the file size.
                        //.filterMimeType() // Filter file format.
                        //.filterDuration() // Filter video duration.
                        .afterFilterVisibility(true) // Show the filtered files, but they are not available.
                        .onResult(new Action<ArrayList<AlbumFile>>() {
                            @Override
                            public void onAction(@NonNull ArrayList<AlbumFile> result) {
                            }
                        })
                        .onCancel(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                                // The user canceled the operation.
                            }
                        })
                        .start();
                break;
            case 1:
                Album.image(getContext()) // Image selection.
                        .multipleChoice()
                        .camera(true)
                        .columnCount(3)
                        .selectCount(3)
                        //.checkedList(mAlbumFiles)
                        //.filterSize() // Filter the file size.
                        //.filterMimeType() // Filter file format.
                        .afterFilterVisibility(true) // Show the filtered files, but they are not available.
                        .onResult(new Action<ArrayList<AlbumFile>>() {
                            @Override
                            public void onAction(@NonNull ArrayList<AlbumFile> result) {
                            }
                        })
                        .onCancel(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        })
                        .start();
                break;
            case 2:
                Album.video(getContext()) // Video selection.
                        .multipleChoice()
                        .camera(true)
                        .columnCount(2)
                        .selectCount(6)
                        //.checkedList(mAlbumFiles)
                        //.filterSize()
                        //.filterMimeType()
                        //.filterDuration()
                        .afterFilterVisibility(true) // Show the filtered files, but they are not available.
                        .onResult(new Action<ArrayList<AlbumFile>>() {
                            @Override
                            public void onAction(@NonNull ArrayList<AlbumFile> result) {
                            }
                        })
                        .onCancel(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        })
                        .start();
                break;
            case 3:
                Album.camera(getContext()) // Camera function.
                        .image() // Take Picture.
                        //.filePath() // File save path, not required.
                        .onResult(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        })
                        .onCancel(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        })
                        .start();
                break;
            case 4:
                Album.camera(getContext())
                        .video() // Record Video.
                        //.filePath()
                        .quality(1) // Video quality, [0, 1].
                        .limitDuration(Long.MAX_VALUE) // The longest duration of the video is in milliseconds.
                        .limitBytes(Long.MAX_VALUE) // Maximum size of the video, in bytes.
                        .onResult(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        })
                        .onCancel(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        })
                        .start();
                break;
            case 5:
                ArrayList<String> imageList = new ArrayList<>();
                Album.gallery(getContext())
                        .checkedList(imageList) // List of image to view: ArrayList<String>.
                        .checkable(true) // Whether there is a selection function.
                        .onResult(new Action<ArrayList<String>>() { // If checkable(false), action not required.
                            @Override
                            public void onAction(@NonNull ArrayList<String> result) {
                            }
                        })
                        .onCancel(new Action<String>() {
                            @Override
                            public void onAction(@NonNull String result) {
                            }
                        });
                break;
        }
    }

    @Override
    public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
        return false;
    }
}